package com.sdleyou.treepro.business.api.pet;

import com.sdleyou.treepro.common.model.utils.ResultVOUtil;
import com.sdleyou.treepro.common.model.vo.ResultVO;
import com.sdleyou.treepro.common.service.PetManager;
import com.sdleyou.treepro.common.service.UserPetManager;
import com.sdleyou.treepro.system.version.ApiVersion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
public class PetController {

    @Autowired
    private UserPetManager petManager;

    /**
     * 获取宠物信息
     */
    @ApiVersion(1)
    @PostMapping("/{version}/pet/info")
    public ResultVO petInfo(@RequestParam("user_id") String userId){
        return ResultVOUtil.success(petManager.getPetInfo(userId));
    }

    /**
     * 添加宠物接口
     */
    @ApiVersion(1)
    @PostMapping("/{version}/pet/add")
    public ResultVO userAddPet(@RequestParam("user_id") String userId){
        return ResultVOUtil.success(petManager.userAddPet(userId));
    }

    /**
     * 寻宝接口
     */
    @ApiVersion(1)
    @PostMapping("/{version}/pet/hunt")
    public ResultVO hunt(@RequestParam("user_id") String userId){
        return ResultVOUtil.success(petManager.petHunt(userId));
    }

    /**
     * 领取寻宝奖励接口
     */
    @ApiVersion(1)
    @PostMapping("/{version}/pet/reward")
    public ResultVO reward(@RequestParam("user_id") String userId,
                           @RequestParam(name="multiple",defaultValue = "1") Integer multiple){
        return ResultVOUtil.success(petManager.huntReward(userId, multiple));
    }
}
